import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;

public class AddingAnAction {

    static WebDriver driver;
    static WebDriverWait wait;

    @BeforeClass
    public static void startFFDriverTest(){

        driver = FireFoxDriver.createFireFoxDriver();
        wait = new WebDriverWait(driver,10);
        Login loginPage = new Login(driver);
        loginPage.typeUserName();
        loginPage.typePassword();
        loginPage.clickSignIn(wait, PageVariableValues.homePageTitle);
    }

    @Test
    public void AddAction(){
        WebElement addActionForm = driver.findElement(By.id("todo_new_action_container"));
        WebElement actionDescription = addActionForm.findElement(By.id("todo_description"));
        actionDescription.sendKeys("Action1.4");

        WebElement actionNotes = addActionForm.findElement(By.id("todo_notes"));
        actionNotes.sendKeys("Action notes22223");

        WebElement addActionToProject = addActionForm.findElement(By.id("todo_project_name"));
        addActionToProject.sendKeys("testProjectDelete121");

        WebElement addContext = addActionForm.findElement(By.id("todo_context_name"));
        addContext.clear();
        addContext.sendKeys("abcde");

        WebElement addDueDate = addActionForm.findElement(By.id("todo_due"));
        addDueDate.sendKeys("20/04/2013");

        WebElement addShowFromDate = addActionForm.findElement(By.id("todo_show_from"));
        addShowFromDate.sendKeys("19/04/2013");

        addActionForm.click();

        WebElement clickSubmitAction = addActionForm.findElement(By.id("todo_new_action_submit"));
        clickSubmitAction.click();

        driver.switchTo().alert().accept();
    }

    @AfterClass
    public static void cleanUpTest(){
        driver.close();
        driver.quit();

    }
}
